package com.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mapper.auto.MajorMapper;
import com.model.auto.Major;
import com.service.IMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author astupidcoder
 * @since 2022-09-14
 */
@Service
public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements IMajorService {
    @Autowired
    private MajorMapper majorMapper;

    @Override
    public List<Major> getMajorNameList() {
        return majorMapper.getMajorNameList();
    }

    @Override
    public List<Major> getByTypeAndName(String type, String name) {
        return majorMapper.getByTypeAndName(type, name);
    }

    @Override
    public Major selectByParams(Integer type, String code, String uniqueCode, String recruitType) {
        return majorMapper.selectByParams(type, code, uniqueCode, recruitType);
    }

    @Override
    public List<Integer> getSchoolIdByMajorName(Integer type, String batch, String majorName1, String majorName2, String majorName3) {
        List<String> majorNameList = new ArrayList<>();
        if(StringUtils.hasText(majorName1)){
            majorNameList.add(majorName1);
        }
        if(StringUtils.hasText(majorName2)){
            majorNameList.add(majorName2);
        }
        if(StringUtils.hasText(majorName3)){
            majorNameList.add(majorName3);
        }
        return majorMapper.getSchoolIdByMajorName(type, batch, majorNameList);
    }
}
